require 'rubygems'
require 'datamapper'

class Item
  include DataMapper::Resource
  property :id, Serial
  property :body, Text
  property :created, DateTime,
           :default => Proc.new {|r, p| DateTime.now }
  property :last_modified, DateTime,
           :default => Proc.new {|r, p| DateTime.now }

  has n, :tags, :through => Resource

  def self.yet(*args)
    self.all(:order =>[:last_modified.desc])  # TODO
  end
end

class Tag
  include DataMapper::Resource
  property :id, Serial
  property :body, String, :nullable => false, :unique => true
  property :created, DateTime,
           :default => Proc.new {|r, p| DateTime.now }

  has n, :items, :through => Resource
end

